Keith Packard: kgames
Reviving Very Old X Code
I've taken the week between Christmas and New Year's off this year. I
didn't really have anything serious planned, just taking a break from
the usual routine. As often happens, I got sucked into doing a project
when I received this simple bug report
Debian Bug #974011
I have been researching old terminal and X games recently, and realized
that much of the code from 'xmille' originated from the terminal game
'mille', which is part of bsdgames.
...
[The copyright and license information] has been stripped out of all
code in the xmille distribution. Also, none of the included materials
give credit to the original author, Ken Arnold.
The reason the 'xmille' source is missing copyright and license
information from the 'mille' files is that they were copied in
before that information was added upstream. Xmille forked from Mille
around 1987 or so. I wrote the UI parts for the system I had at the
time, which was running X10R4. A very basic port to X11 was done at
some point, and that's what Debian has in the archive today.
At some point in the 90s, I ported Xmille to the
Athena widget set,
including several custom widgets in an Xaw extension library,
Xkw. It's a lot better than the version in Debian, including displaying the
cards correctly (the Debian version has some pretty bad color issues).
Here's what the current Debian version looks like:
Fixing The Bug
To fix the missing copyright and license information, I imported the
mille source code into the "latest" Xaw-based version. The updated
mille code had a number of bug fixes and improvements, along with the
copyright information.
That should have been sufficient to resolve the issue and I could have
constructed a suitable source package from whatever bits were needed
and and uploaded that as a replacement 'xmille' package.
However, at some later point, I had actually merged xmille into a
larger package, 'kgames', which also included a number of other
games, including Reversi, Dominoes, Cribbage and ten Solitaire/Patience
variants. (as an aside, those last ten games formed the basis for my
Patience Palm Pilot application, which seems to have inspired an
Android App of the same name...)
So began my
yak shaving holiday.
Building Kgames in 2020
Ok, so getting this old source code running should be easy, right?
It's just a bunch of C code designed in the 80s and 90s to work on
VAXen and their kin. How hard could it be?
- Everything was a 32-bit computer back then; pointers and ints were both 32 bits, so you could cast them with wild abandon and cause no problems. Today, testing revealed segfaults in some corners of the code.
- It's K&R C code. Remember that the first version of ANSI-C didn't come out until 1989, and it was years later that we could reliably expect to find an ANSI compiler with a random Unix box.
- It's X11 code. Fortunately (?), X11 hasn't changed since these applications were written, so at least that part still works just fine. Imagine trying to build Windows or Mac OS code from the early 90's on a modern OS...
- KLabel. Shows a text string. It allows the string to be left, center or right justified. And that's about it.
- KCommand. A push button, which uses KLabel for the underlying presentation.
- KToggle. A push-on/push-off button, which uses KCommand for most of the implementation. Also supports 'radio groups' where pushing one on makes the others in the group turn off.
- KMenuButton. A button for bringing up a menu widget; this is some pretty simple behavior built on top of KCommand.
- KSimpleMenu, KSmeBSB, KSmeLine. These three create pop-up menus; KSimpleMenu creates a container which can hold any number of KSmeBSB (string) and KSmeLine (separator lines) objects).
- KTextLine. A single line text entry widget.